<?php
class BaseAction extends Action {

	public function _initialize(){

		$this->assign('title','后台管理系统');
		if(!$_SESSION['WKEIN_LGOIN']){
			$this->error('您还没有登陆！',U('Login/index'));
		}

	}

	/**
	 * 获取控制台左侧菜单
	 */
	public function getleftnav(){
		$map['group']  = 'Admin';
		$map['show'] = 1;
		$info = D('nav')->where($map)->select();

		foreach($info as $k => $v){
			$v['url']  =  U('Admin/'.$v['controller'].'/'.$v['action']);

			if($v['pid'] == 0){
				$leftmenu[$v['id']] = $v;
			}else{
				$leftmenu[$v['pid']]['next'][$v['id']] = $v;
			}
		}

		return $leftmenu;
	}

	/**
	 * 页面初始化时调用
	 * {@inheritDoc}
	 * @see Action::show()
	 */
	public function show($path){

		if(!$path){
			$path =  MODULE_NAME.'/'.ACTION_NAME;
		}

		echo $path;
		// exit();

		$this->assign('controller_name',MODULE_NAME);
		$this->assign('action_name',ACTION_NAME);
		$leftmenu = $this->getleftnav();
		$this->assign('leftmenu',$leftmenu);
		$this->assign('temp_contentfile',$path);
		$this->assign('temp_footerjs',$path.'_js');
		$this->display('Base/Model');
	}

}
